package cn.puge.mertisfront.controller;


import cn.puge.commonutils.R;
import cn.puge.mertisfront.entity.PugeWorkfile;
import cn.puge.mertisfront.service.PugeWorkfileService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 * 工作文件
 * @author LIJW
 * @since 2020-09-18
 */
@RestController
@RequestMapping("/mertisfront/puge-workfile")
@CrossOrigin
public class PugeWorkfileController {

    @Autowired
    private PugeWorkfileService pugeWorkfileService;

    /**
     * 获取所有工作文件
     * @return
     */
    @GetMapping("getAllFile/{page}/{limit}")
    public R getAllFile(@PathVariable long page,
                        @PathVariable long limit){

        Page<PugeWorkfile> pugeWorkfilePage = new Page<>(page,limit);
        QueryWrapper<PugeWorkfile> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc("gmt_create");

        pugeWorkfileService.page(pugeWorkfilePage,queryWrapper);
        return R.ok().data("total",pugeWorkfilePage.getTotal()).data("pugeWorkfiles",pugeWorkfilePage.getRecords());
    }




}

